package com.xiaobias.distributed.pan.web.file;

import com.xiaobias.distributed.pan.service.BaiduPanFileService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.Set;

@Controller
@RequestMapping({"/baidu/pan/file/download"})
public class BaiduPanDownloadController {
    @Resource
    private BaiduPanFileService baiduPanFileService;

    @RequestMapping({"download.html"})
    public ModelAndView filePage(ModelAndView modelAndView) {
        modelAndView.setViewName("/pan/file/download");
        return modelAndView;
    }

    @RequestMapping
    @ResponseBody
    public String downloadFile(String fileName, String tempPath) {
        return this.baiduPanFileService.downloadFile(fileName, tempPath);
    }
}